package org.wotou.authority.dto;

/**
 * 传输结果对象
 *
 * @author zhangQ
 * @date 2017/12/8
 */
public class ResultDTO implements java.io.Serializable {
    private static final long serialVersionUID = 1L;

    public ResultDTO() {
        super();
        this.code = FAIL;
    }

    /**
     * 成功返回码
     */
    public static Integer SUCCESS = 0;
    /**
     * 失败返回码 1
     */
    public static Integer FAIL = 1;
    /**
     * 系统错误
     */
    public static Integer SYSTEM_ERROR = 500;
    /**
     * 成功或失败代码 成功是0 失败是非0
     */
    private Integer code;
    /**
     * 业务码
     */
    private Integer serviceCode;
    /**
     * 后台需要给前台的信息提示，如失败后，应该设置失败的具体原因
     */
    private String message;
    /**
     * 成功后返回的结果
     */
    private Object result;

    public ResultDTO(Integer code, Integer serviceCode, String message, Object result) {
        super();
        this.code = code;
        this.serviceCode = serviceCode;
        this.message = message;
        this.result = result;
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Integer getServiceCode() {
        return serviceCode;
    }

    public void setServiceCode(Integer serviceCode) {
        this.serviceCode = serviceCode;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getResult() {
        return result;
    }

    public void setResult(Object result) {
        this.result = result;
    }

    public static final ResultDTO getResultSuccess(Object result) {
        ResultDTO resultdto = new ResultDTO();
        resultdto.setCode(SUCCESS);
        resultdto.setMessage("操作成功");
        resultdto.setResult(result);
        return resultdto;
    }

    public static final ResultDTO getResultFail(String message, Object result) {
        ResultDTO resultdto = new ResultDTO();
        resultdto.setCode(FAIL);
        resultdto.setMessage(message);
        resultdto.setResult(result);
        return resultdto;
    }
}